package com.sike.entity;

import java.util.HashMap;
import java.util.Map;

/**
 * @author vito
 * @version 1.0
 */
public class R {
    private boolean success;
    private String code;
    private String message;
    private Map<String, Object> data = new HashMap<>();

    public R(boolean success, String code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    public static R ok() {
        return new R(true, "20000", null);
    }

    public static R error() {
        return new R(false, "50000", null);
    }

    public R message(String message) {
        this.message = message;
        return this;
    }

    public R data(String key, Object value) {
        this.data.put(key, value);
        return this;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }
}

